<template>
	<view>
		<u-navbar
			:safeAreaInsetTop="true"
			title="工程日志列表"
			:fixed="true"
			:placeholder="true"
			left-text="返回"
			rightIcon="map"
			@rightClick="rightClick"
			@leftClick="goback"
		>
		</u-navbar>
		<buildinfo :buildid='buildid'></buildinfo>
		<u-button class="custom-style" @click="openpage" type="success" loadingText="加载中" size="normal"
			icon="weixin-fill">添加工程日志</u-button>
		<!-- <u-search placeholder="请输入关键字" v-model="keyword"></u-search> -->
		<u-search v-model="keyword" :show-action="false" @change="getlist" placeholder="请输入关键字"></u-search>
		<u-list @scrolltolower="scrolltolower">
			<u-list-item v-for="(item, index) in buildlist" :key="index">
				<u-cell :title="item.CreateTime" isLink @click="openpage" :name="item.Id"
					icon="https://cdn.uviewui.com/uview/example/toast.png">

				</u-cell>
			</u-list-item>
		</u-list>
	</view>
</template>

<script>
	import {
		getbuilddailylist
	} from '@/common/api.js'
	import buildinfo from "./c_buildinfo.vue"
	export default {
		components: {
		  buildinfo
		},
		data() {
			return {
				buildlist: [],
				keyword: "",
				buildid:null,
			}
		},
		onLoad(option) {
			this.buildid=option.buildid
			this.getlist()
		},
		methods: {
			rightClick()
			{
				uni.navigateTo({
					url: "map?buildid="+this.buildid
				})
			},
			goback()
			{
				uni.navigateBack({
					delta: 1
				});
			},
			openpage(e) {
				if (!e) {
					uni.$u.route({
						url: "pages/index/builddailydetail?buildid="+this.buildid
					})
				} else {
					uni.$u.route({
						url: "pages/index/builddailyView?buildid="+this.buildid+"&id="+ (e.name || '')
					})
				}
			},
			getlist() {
				// let querytype = this.$route.query.querytype
				let para = {
					Parameters: [],
					orderBys:["CreateTime desc"]
				}
				if (this.keyword != "") {
					para.Parameters.push({
						FieldName: "CreateTime",
						ConditionalType: "Like",
						FieldValue: this.keyword
					})
				}

				// if (querytype == "日志") {


				// }
				getbuilddailylist(para).then(res => {
					this.buildlist = res.data
				})
			}
		},
	}
</script>

<style>
	.custom-style {}
</style>
